package com.example.service;

import com.example.repo.PersonRepo;
import com.example.vo.Person;
import com.fasterxml.jackson.databind.ser.std.IterableSerializer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service
public class PersonService {

    @Resource
    public PersonRepo personRepo;

    @Transactional
    public void save(Person person){
        personRepo.save(person);
    }
    @Transactional
    public String delete(int id){
        if (personRepo.exists(id)){
            personRepo.delete(id);
            return "id=" +id +",delete ok";
        }else
            return "不存在此记录";
    }
    @Transactional
    public Iterable<Person> findAll(){
        return personRepo.findAll();
    }
}
